/*
 * AssociadoCadastrar.java
 *
 * Created on 12/02/2009, 15:54:19
 * Copyright Jaime Junior
 */

//22.06
package Adecot.Associados;

//Importações
import Adecot.*;
import Controller.AssociacaoBO;
import Controller.AssociadoBO;
import Controller.BancoBO;
import Controller.CidadeBO;
import Controller.EstadoBO;
import Controller.Facade.IceDecorator;
import Controller.Facade.ValidaFacade;
import Model.Associacao;
import Model.Associado;
import Model.Banco;
import Model.Cidade;
import Model.Endereco;
import Report.XML.CriaQuery;
import Report.XML.ManipulaXML;
import Report.XML.Relatorio;
import com.icesoft.faces.component.ext.*;
import com.icesoft.faces.component.jsfcl.data.*;
import com.icesoft.faces.component.panellayout.PanelLayout;
import com.icesoft.faces.component.panelpopup.PanelPopup;
import com.icesoft.faces.component.selectinputdate.SelectInputDate;
import com.icesoft.faces.component.selectinputtext.SelectInputText;
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import java.io.File;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.FacesException;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.CharacterConverter;
import javax.faces.event.ValueChangeEvent;
import javax.faces.model.SelectItem;
import javax.faces.validator.DoubleRangeValidator;
import javax.xml.parsers.ParserConfigurationException;

/**
 * <p>Page bean that corresponds to a similarly named JSP page.  This
 * class contains component definitions (and initialization code) for
 * all components that you have defined on this page, as well as
 * lifecycle methods and event handlers where you may add behavior
 * to respond to incoming events.</p>
 */
public class AssociadoCadastrar extends AbstractPageBean {
   // <editor-fold defaultstate="collapsed" desc="Managed Component Definition">

   private int __placeholder;
   private boolean parar;

   public boolean isParar() {
      return parar;
   }

   public void setParar(boolean parar) {
      this.parar = parar;
   }
   private DefaultSelectionItems nomeBusca = new DefaultSelectionItems();

   public DefaultSelectionItems getNomeBusca() {
      return nomeBusca;
   }

   public void setNomeBusca(DefaultSelectionItems nomeBusca) {
      this.nomeBusca = nomeBusca;
   }

   /**
    * <p>Automatically managed component initialization.  <strong>WARNING:</strong>
    * This method is automatically generated, so any user-specified code inserted
    * here is subject to being replaced.</p>
    */
   private void _init() throws Exception {
   }
   private HtmlInputText campoNumeroAssociado = new HtmlInputText();

   public HtmlInputText getCampoNumeroAssociado() {
      return campoNumeroAssociado;
   }

   public void setCampoNumeroAssociado(HtmlInputText hit) {
      this.campoNumeroAssociado = hit;
   }
   private HtmlInputText campoNome = new HtmlInputText();

   public HtmlInputText getCampoNome() {
      return campoNome;
   }

   public void setCampoNome(HtmlInputText hit) {
      this.campoNome = hit;
   }
   private HtmlInputText campoEndereco = new HtmlInputText();

   public HtmlInputText getCampoEndereco() {
      return campoEndereco;
   }

   public void setCampoEndereco(HtmlInputText hit) {
      this.campoEndereco = hit;
   }
   private HtmlInputText campoBairro = new HtmlInputText();

   public HtmlInputText getCampoBairro() {
      return campoBairro;
   }

   public void setCampoBairro(HtmlInputText hit) {
      this.campoBairro = hit;
   }
   private HtmlInputText campoComplemento = new HtmlInputText();

   public HtmlInputText getCampoComplemento() {
      return campoComplemento;
   }

   public void setCampoComplemento(HtmlInputText hit) {
      this.campoComplemento = hit;
   }
   private HtmlInputText campoSitio = new HtmlInputText();

   public HtmlInputText getCampoSitio() {
      return campoSitio;
   }

   public void setCampoSitio(HtmlInputText hit) {
      this.campoSitio = hit;
   }
   private HtmlInputText campoTelefone = new HtmlInputText();

   public HtmlInputText getCampoTelefone() {
      return campoTelefone;
   }

   public void setCampoTelefone(HtmlInputText hit) {
      this.campoTelefone = hit;
   }
   private HtmlInputText campoAgencia = new HtmlInputText();

   public HtmlInputText getCampoAgencia() {
      return campoAgencia;
   }

   public void setCampoAgencia(HtmlInputText hit) {
      this.campoAgencia = hit;
   }
   private HtmlInputText campoNumero = new HtmlInputText();

   public HtmlInputText getCampoNumero() {
      return campoNumero;
   }

   public void setCampoNumero(HtmlInputText hit) {
      this.campoNumero = hit;
   }
   private HtmlInputText campoEmail = new HtmlInputText();

   public HtmlInputText getCampoEmail() {
      return campoEmail;
   }

   public void setCampoEmail(HtmlInputText hit) {
      this.campoEmail = hit;
   }
   private HtmlInputText campoLogin = new HtmlInputText();

   public HtmlInputText getCampoLogin() {
      return campoLogin;
   }

   public void setCampoLogin(HtmlInputText hit) {
      this.campoLogin = hit;
   }
   private DefaultSelectedData estadoSelecionado = new DefaultSelectedData();

   public DefaultSelectedData getEstadoSelecionado() {
      return estadoSelecionado;
   }

   public void setEstadoSelecionado(DefaultSelectedData dsd) {
      this.estadoSelecionado = dsd;
   }
   private DefaultSelectionItems estados = new DefaultSelectionItems();

   public DefaultSelectionItems getEstados() {
      return estados;
   }

   public void setEstados(DefaultSelectionItems dsi) {
      this.estados = dsi;
   }
   private HtmlSelectOneMenu comboEstado = new HtmlSelectOneMenu();

   public HtmlSelectOneMenu getComboEstado() {
      return comboEstado;
   }

   public void setComboEstado(HtmlSelectOneMenu hsom) {
      this.comboEstado = hsom;
   }
   private DefaultSelectedData cidadeSelecionada = new DefaultSelectedData();

   public DefaultSelectedData getCidadeSelecionada() {
      return cidadeSelecionada;
   }

   public void setCidadeSelecionada(DefaultSelectedData dsd) {
      this.cidadeSelecionada = dsd;
   }
   private DefaultSelectionItems cidades = new DefaultSelectionItems();

   public DefaultSelectionItems getCidades() {
      return cidades;
   }

   public void setCidades(DefaultSelectionItems dsi) {
      this.cidades = dsi;
   }
   private HtmlSelectOneMenu comboCidade = new HtmlSelectOneMenu();

   public HtmlSelectOneMenu getComboCidade() {
      return comboCidade;
   }

   public void setComboCidade(HtmlSelectOneMenu hsom) {
      this.comboCidade = hsom;
   }
   private DefaultSelectedData bancoSelecionado = new DefaultSelectedData();

   public DefaultSelectedData getBancoSelecionado() {
      return bancoSelecionado;
   }

   public void setBancoSelecionado(DefaultSelectedData dsd) {
      this.bancoSelecionado = dsd;
   }
   private DefaultSelectionItems bancos = new DefaultSelectionItems();

   public DefaultSelectionItems getBancos() {
      return bancos;
   }

   public void setBancos(DefaultSelectionItems dsi) {
      this.bancos = dsi;
   }
   private HtmlSelectOneMenu comboBanco = new HtmlSelectOneMenu();

   public HtmlSelectOneMenu getComboBanco() {
      return comboBanco;
   }

   public void setComboBanco(HtmlSelectOneMenu hsom) {
      this.comboBanco = hsom;
   }
   private PopupBean panelPopup1Bean = new PopupBean();

   public PopupBean getPanelPopup1Bean() {
      return panelPopup1Bean;
   }

   public void setPanelPopup1Bean(PopupBean pb) {
      this.panelPopup1Bean = pb;
   }
   private HtmlInputText campoCep = new HtmlInputText();

   public HtmlInputText getCampoCep() {
      return campoCep;
   }

   public void setCampoCep(HtmlInputText hit) {
      this.campoCep = hit;
   }
   private HtmlInputText campoCelular = new HtmlInputText();

   public HtmlInputText getCampoCelular() {
      return campoCelular;
   }

   public void setCampoCelular(HtmlInputText hit) {
      this.campoCelular = hit;
   }
   private HtmlInputText campoTelComercial = new HtmlInputText();

   public HtmlInputText getCampoTelComercial() {
      return campoTelComercial;
   }

   public void setCampoTelComercial(HtmlInputText hit) {
      this.campoTelComercial = hit;
   }
   private DefaultSelectedData associacaoSelecionada = new DefaultSelectedData();

   public DefaultSelectedData getAssociacaoSelecionada() {
      return associacaoSelecionada;
   }

   public void setAssociacaoSelecionada(DefaultSelectedData dsd) {
      this.associacaoSelecionada = dsd;
   }
   private DefaultSelectionItems associacoes = new DefaultSelectionItems();

   public DefaultSelectionItems getAssociacoes() {
      return associacoes;
   }

   public void setAssociacoes(DefaultSelectionItems dsi) {
      this.associacoes = dsi;
   }
   private HtmlSelectOneMenu comboAssociacao = new HtmlSelectOneMenu();

   public HtmlSelectOneMenu getComboAssociacao() {
      return comboAssociacao;
   }

   public void setComboAssociacao(HtmlSelectOneMenu hsom) {
      this.comboAssociacao = hsom;
   }
   private SelectInputDateBean dataNascimentoSelecionada = new SelectInputDateBean();

   public SelectInputDateBean getDataNascimentoSelecionada() {
      return dataNascimentoSelecionada;
   }

   public void setDataNascimentoSelecionada(SelectInputDateBean sidb) {
      this.dataNascimentoSelecionada = sidb;
   }
   private HtmlInputSecret campoSenha = new HtmlInputSecret();

   public HtmlInputSecret getCampoSenha() {
      return campoSenha;
   }

   public void setCampoSenha(HtmlInputSecret his) {
      this.campoSenha = his;
   }
   private HtmlInputSecret campoConfirmaSenha = new HtmlInputSecret();

   public HtmlInputSecret getCampoConfirmaSenha() {
      return campoConfirmaSenha;
   }

   public void setCampoConfirmaSenha(HtmlInputSecret his) {
      this.campoConfirmaSenha = his;
   }
   private CharacterConverter characterConverter1 = new CharacterConverter();

   public CharacterConverter getCharacterConverter1() {
      return characterConverter1;
   }

   public void setCharacterConverter1(CharacterConverter cc) {
      this.characterConverter1 = cc;
   }
   private HtmlCommandButton botaoNovo = new HtmlCommandButton();

   public HtmlCommandButton getBotaoNovo() {
      return botaoNovo;
   }

   public void setBotaoNovo(HtmlCommandButton hcb) {
      this.botaoNovo = hcb;
   }
   private HtmlCommandButton botaoConsultar = new HtmlCommandButton();

   public HtmlCommandButton getBotaoConsultar() {
      return botaoConsultar;
   }

   public void setBotaoConsultar(HtmlCommandButton hcb) {
      this.botaoConsultar = hcb;
   }
   private HtmlCommandButton botaoAlterar = new HtmlCommandButton();

   public HtmlCommandButton getBotaoAlterar() {
      return botaoAlterar;
   }

   public void setBotaoAlterar(HtmlCommandButton hcb) {
      this.botaoAlterar = hcb;
   }
   private HtmlCommandButton botaoDesativar = new HtmlCommandButton();

   public HtmlCommandButton getBotaoDesativar() {
      return botaoDesativar;
   }

   public void setBotaoDesativar(HtmlCommandButton hcb) {
      this.botaoDesativar = hcb;
   }
   private HtmlCommandButton botaoLimpar = new HtmlCommandButton();

   public HtmlCommandButton getBotaoLimpar() {
      return botaoLimpar;
   }

   public void setBotaoLimpar(HtmlCommandButton hcb) {
      this.botaoLimpar = hcb;
   }
   private PopupBean panelPopup1Bean1 = new PopupBean();

   public PopupBean getPanelPopup1Bean1() {
      return panelPopup1Bean1;
   }

   public void setPanelPopup1Bean1(PopupBean pb) {
      this.panelPopup1Bean1 = pb;
   }
   private PanelPopup painelConsulta = new PanelPopup();

   public PanelPopup getPainelConsulta() {
      return painelConsulta;
   }

   public void setPainelConsulta(PanelPopup pp) {
      this.painelConsulta = pp;
   }
   private SelectInputText campoBusca = new SelectInputText();

   public SelectInputText getCampoBusca() {
      return campoBusca;
   }

   public void setCampoBusca(SelectInputText sit) {
      this.campoBusca = sit;
   }
   private HtmlInputText cpf = new HtmlInputText();

   public HtmlInputText getCpf() {
      return cpf;
   }

   public void setCpf(HtmlInputText hit) {
      this.cpf = hit;
   }
   private PopupBean panelPopup1Bean2 = new PopupBean();

   public PopupBean getPanelPopup1Bean2() {
      return panelPopup1Bean2;
   }

   public void setPanelPopup1Bean2(PopupBean pb) {
      this.panelPopup1Bean2 = pb;
   }
   private PanelPopup painelSair = new PanelPopup();

   public PanelPopup getPainelSair() {
      return painelSair;
   }

   public void setPainelSair(PanelPopup pp) {
      this.painelSair = pp;
   }
   private PanelLayout painelAvisoCorpo = new PanelLayout();

   public PanelLayout getPainelAvisoCorpo() {
      return painelAvisoCorpo;
   }

   public void setPainelAvisoCorpo(PanelLayout pl) {
      this.painelAvisoCorpo = pl;
   }
   private HtmlCommandButton botaoAvisoSim = new HtmlCommandButton();

   public HtmlCommandButton getBotaoAvisoSim() {
      return botaoAvisoSim;
   }

   public void setBotaoAvisoSim(HtmlCommandButton hcb) {
      this.botaoAvisoSim = hcb;
   }
   private HtmlCommandButton botaoNaoAviso = new HtmlCommandButton();

   public HtmlCommandButton getBotaoNaoAviso() {
      return botaoNaoAviso;
   }

   public void setBotaoNaoAviso(HtmlCommandButton hcb) {
      this.botaoNaoAviso = hcb;
   }
   private HtmlOutputText msgAvisoResultado = new HtmlOutputText();

   public HtmlOutputText getMsgAvisoResultado() {
      return msgAvisoResultado;
   }

   public void setMsgAvisoResultado(HtmlOutputText hot) {
      this.msgAvisoResultado = hot;
   }
   private PanelPopup painelAviso = new PanelPopup();

   public PanelPopup getPainelAviso() {
      return painelAviso;
   }

   public void setPainelAviso(PanelPopup pp) {
      this.painelAviso = pp;
   }
   private DefaultSelectedData tipoContaSelecionada = new DefaultSelectedData();

   public DefaultSelectedData getTipoContaSelecionada() {
      return tipoContaSelecionada;
   }

   public void setTipoContaSelecionada(DefaultSelectedData dsd) {
      this.tipoContaSelecionada = dsd;
   }
   private DefaultSelectionItems contas = new DefaultSelectionItems();

   public DefaultSelectionItems getContas() {
      return contas;
   }

   public void setContas(DefaultSelectionItems dsi) {
      this.contas = dsi;
   }
   private HtmlSelectOneMenu comboTipoConta = new HtmlSelectOneMenu();

   public HtmlSelectOneMenu getComboTipoConta() {
      return comboTipoConta;
   }

   public void setComboTipoConta(HtmlSelectOneMenu hsom) {
      this.comboTipoConta = hsom;
   }
   private DefaultSelectedData sexoSelecionado = new DefaultSelectedData();

   public DefaultSelectedData getSexoSelecionado() {
      return sexoSelecionado;
   }

   public void setSexoSelecionado(DefaultSelectedData dsd) {
      this.sexoSelecionado = dsd;
   }
   private DefaultSelectionItems sexos = new DefaultSelectionItems();

   public DefaultSelectionItems getSexos() {
      return sexos;
   }

   public void setSexos(DefaultSelectionItems dsi) {
      this.sexos = dsi;
   }
   private HtmlSelectOneMenu comboSexo = new HtmlSelectOneMenu();

   public HtmlSelectOneMenu getComboSexo() {
      return comboSexo;
   }

   public void setComboSexo(HtmlSelectOneMenu hsom) {
      this.comboSexo = hsom;
   }
   private HtmlCommandButton botaoSairSim = new HtmlCommandButton();

   public HtmlCommandButton getBotaoSairSim() {
      return botaoSairSim;
   }

   public void setBotaoSairSim(HtmlCommandButton hcb) {
      this.botaoSairSim = hcb;
   }
   private HtmlCommandButton botaoSairNao = new HtmlCommandButton();

   public HtmlCommandButton getBotaoSairNao() {
      return botaoSairNao;
   }

   public void setBotaoSairNao(HtmlCommandButton hcb) {
      this.botaoSairNao = hcb;
   }
   private PopupBean panelPopup1Bean3 = new PopupBean();

   public PopupBean getPanelPopup1Bean3() {
      return panelPopup1Bean3;
   }

   public void setPanelPopup1Bean3(PopupBean pb) {
      this.panelPopup1Bean3 = pb;
   }
   private PanelPopup painelMensagem = new PanelPopup();

   public PanelPopup getPainelMensagem() {
      return painelMensagem;
   }

   public void setPainelMensagem(PanelPopup pp) {
      this.painelMensagem = pp;
   }
   private HtmlOutputText msgMensagemResultado = new HtmlOutputText();

   public HtmlOutputText getMsgMensagemResultado() {
      return msgMensagemResultado;
   }

   public void setMsgMensagemResultado(HtmlOutputText hot) {
      this.msgMensagemResultado = hot;
   }
   private HtmlCommandButton botaoMensagemOk = new HtmlCommandButton();

   public HtmlCommandButton getBotaoMensagemOk() {
      return botaoMensagemOk;
   }

   public void setBotaoMensagemOk(HtmlCommandButton hcb) {
      this.botaoMensagemOk = hcb;
   }
   private DoubleRangeValidator doubleRangeValidator1 = new DoubleRangeValidator();

   public DoubleRangeValidator getDoubleRangeValidator1() {
      return doubleRangeValidator1;
   }

   public void setDoubleRangeValidator1(DoubleRangeValidator drv) {
      this.doubleRangeValidator1 = drv;
   }
   private HtmlCommandButton botaoCadastrar = new HtmlCommandButton();

   public HtmlCommandButton getBotaoCadastrar() {
      return botaoCadastrar;
   }

   public void setBotaoCadastrar(HtmlCommandButton hcb) {
      this.botaoCadastrar = hcb;
   }
   private HtmlGraphicImage imagemSituacao = new HtmlGraphicImage();

   public HtmlGraphicImage getImagemSituacao() {
      return imagemSituacao;
   }

   public void setImagemSituacao(HtmlGraphicImage hgi) {
      this.imagemSituacao = hgi;
   }
   private HtmlOutputText msgPainelSair = new HtmlOutputText();

   public HtmlOutputText getMsgPainelSair() {
      return msgPainelSair;
   }

   public void setMsgPainelSair(HtmlOutputText hot) {
      this.msgPainelSair = hot;
   }
   private HtmlCommandButton botaoConsultaOk = new HtmlCommandButton();

   public HtmlCommandButton getBotaoConsultaOk() {
      return botaoConsultaOk;
   }

   public void setBotaoConsultaOk(HtmlCommandButton hcb) {
      this.botaoConsultaOk = hcb;
   }
   private HtmlCommandButton botaoConsultaCancelar = new HtmlCommandButton();

   public HtmlCommandButton getBotaoConsultaCancelar() {
      return botaoConsultaCancelar;
   }

   public void setBotaoConsultaCancelar(HtmlCommandButton hcb) {
      this.botaoConsultaCancelar = hcb;
   }
   private HtmlMessage msgCpf = new HtmlMessage();

   public HtmlMessage getMsgCpf() {
      return msgCpf;
   }

   public void setMsgCpf(HtmlMessage hm) {
      this.msgCpf = hm;
   }
   private HtmlMessage msgDataNascimento = new HtmlMessage();

   public HtmlMessage getMsgDataNascimento() {
      return msgDataNascimento;
   }

   public void setMsgDataNascimento(HtmlMessage hm) {
      this.msgDataNascimento = hm;
   }
   private HtmlMessage msgCampoNome = new HtmlMessage();

   public HtmlMessage getMsgCampoNome() {
      return msgCampoNome;
   }

   public void setMsgCampoNome(HtmlMessage hm) {
      this.msgCampoNome = hm;
   }
   private HtmlMessage msgNumeroAssociado = new HtmlMessage();

   public HtmlMessage getMsgNumeroAssociado() {
      return msgNumeroAssociado;
   }

   public void setMsgNumeroAssociado(HtmlMessage hm) {
      this.msgNumeroAssociado = hm;
   }
   private HtmlMessage msgComboAssociacao = new HtmlMessage();

   public HtmlMessage getMsgComboAssociacao() {
      return msgComboAssociacao;
   }

   public void setMsgComboAssociacao(HtmlMessage hm) {
      this.msgComboAssociacao = hm;
   }
   private HtmlMessage msgComboSexo = new HtmlMessage();

   public HtmlMessage getMsgComboSexo() {
      return msgComboSexo;
   }

   public void setMsgComboSexo(HtmlMessage hm) {
      this.msgComboSexo = hm;
   }
   private HtmlMessage msgTelefone = new HtmlMessage();

   public HtmlMessage getMsgTelefone() {
      return msgTelefone;
   }

   public void setMsgTelefone(HtmlMessage hm) {
      this.msgTelefone = hm;
   }
   private HtmlMessage msgCelular = new HtmlMessage();

   public HtmlMessage getMsgCelular() {
      return msgCelular;
   }

   public void setMsgCelular(HtmlMessage hm) {
      this.msgCelular = hm;
   }
   private HtmlMessage msgTelComercial = new HtmlMessage();

   public HtmlMessage getMsgTelComercial() {
      return msgTelComercial;
   }

   public void setMsgTelComercial(HtmlMessage hm) {
      this.msgTelComercial = hm;
   }
   private HtmlMessage msgCampoEndereco = new HtmlMessage();

   public HtmlMessage getMsgCampoEndereco() {
      return msgCampoEndereco;
   }

   public void setMsgCampoEndereco(HtmlMessage hm) {
      this.msgCampoEndereco = hm;
   }
   private HtmlMessage msgCampoBairro = new HtmlMessage();

   public HtmlMessage getMsgCampoBairro() {
      return msgCampoBairro;
   }

   public void setMsgCampoBairro(HtmlMessage hm) {
      this.msgCampoBairro = hm;
   }
   private HtmlMessage msgComboCep = new HtmlMessage();

   public HtmlMessage getMsgComboCep() {
      return msgComboCep;
   }

   public void setMsgComboCep(HtmlMessage hm) {
      this.msgComboCep = hm;
   }
   private HtmlMessage msgCampoAgencia = new HtmlMessage();

   public HtmlMessage getMsgCampoAgencia() {
      return msgCampoAgencia;
   }

   public void setMsgCampoAgencia(HtmlMessage hm) {
      this.msgCampoAgencia = hm;
   }
   private HtmlMessage msgCampoNumero = new HtmlMessage();

   public HtmlMessage getMsgCampoNumero() {
      return msgCampoNumero;
   }

   public void setMsgCampoNumero(HtmlMessage hm) {
      this.msgCampoNumero = hm;
   }
   private HtmlOutputText msgMensagemOperacao = new HtmlOutputText();

   public HtmlOutputText getMsgMensagemOperacao() {
      return msgMensagemOperacao;
   }

   public void setMsgMensagemOperacao(HtmlOutputText hot) {
      this.msgMensagemOperacao = hot;
   }
   private SelectInputDateBean selectInputDate1Bean = new SelectInputDateBean();

   public SelectInputDateBean getSelectInputDate1Bean() {
      return selectInputDate1Bean;
   }

   public void setSelectInputDate1Bean(SelectInputDateBean sidb) {
      this.selectInputDate1Bean = sidb;
   }
   private SelectInputDate dateDataNascimento = new SelectInputDate();

   public SelectInputDate getDateDataNascimento() {
      return dateDataNascimento;
   }

   public void setDateDataNascimento(SelectInputDate sid) {
      this.dateDataNascimento = sid;
   }
   private HtmlCommandButton botaoImprimir = new HtmlCommandButton();

   public HtmlCommandButton getBotaoImprimir() {
      return botaoImprimir;
   }

   public void setBotaoImprimir(HtmlCommandButton hcb) {
      this.botaoImprimir = hcb;
   }

   // </editor-fold>
   /**
    * <p>Construct a new Page bean instance.</p>
    */
   public AssociadoCadastrar() {
   }

   /**
    * <p>Callback method that is called whenever a page is navigated to,
    * either directly via a URL, or indirectly via page navigation.
    * Customize this method to acquire resources that will be needed
    * for event handlers and lifecycle methods, whether or not this
    * page is performing post back processing.</p>
    *
    * <p>Note that, if the current request is a postback, the property
    * values of the components do <strong>not</strong> represent any
    * values submitted with this request.  Instead, they represent the
    * property values that were saved for this view when it was rendered.</p>
    */
   @Override
   public void init() {
      // Perform initializations inherited from our superclass
      super.init();


      // Perform application initialization that must complete
      // *before* managed components are initialized
      // TODO - add your own initialiation code here

      // <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
      // Initialize automatically managed components
      // *Note* - this logic should NOT be modified
      try {
         _init();
      } catch (Exception e) {
         log("AssociadoCadastrar Initialization Failure", e);
         throw e instanceof FacesException ? (FacesException) e : new FacesException(e);
      }

      ativo();
      //montando combo com o estado do Paraná selecionado
      estados.clear();
      setEstados(new IceDecorator(EstadoBO.class).montaCombo());
      comboEstado.setValue(new Integer(15));

      //montando combo com a Associação Adecot selecionada
      associacoes.clear();
      setAssociacoes(new IceDecorator(AssociacaoBO.class).montaCombo());
      comboAssociacao.setValue(new Integer(1));

      //montando combo de bancos
      bancos.clear();
      this.setBancos(new IceDecorator(BancoBO.class).montaCombo());

      //montando combo de sexo, com o sexo masculino selecionado
      sexos.clear();
      sexos.add(new SelectItem("Masculino", "Masculino"));
      sexos.add(new SelectItem("Feminino", "Feminino"));
      comboSexo.setValue("Masculino");

      //montando combo de tipo de contas com conta corrente selecionada
      contas.clear();
      contas.add(new SelectItem("Corrente", "Corrente"));
      contas.add(new SelectItem("Poupanca", "Poupanca"));
      comboTipoConta.setValue("Corrente");

      //setando os botoes
      botaoNovo.setDisabled(true);
      botaoConsultar.setDisabled(false);
      botaoAlterar.setDisabled(true);

      //setando os paineis para começarem escondidos
      painelConsulta.setRendered(false);
      painelSair.setRendered(false);
      painelAviso.setRendered(false);
      painelMensagem.setRendered(false);

      nomeBusca.clear();
      habilitarCampos();
      this.limparCampos();



   // </editor-fold>
   // Perform application initialization that must complete
   // *after* managed components are initialized
   // TODO - add your own initialization code here

   }

   /**
    * <p>Callback method that is called after the component tree has been
    * restored, but before any event processing takes place.  This method
    * will <strong>only</strong> be called on a postback request that
    * is processing a form submit.  Customize this method to allocate
    * resources that will be required in your event handlers.</p>
    */
   @Override
   public void preprocess() {
   }

   /**
    * <p>Callback method that is called just before rendering takes place.
    * This method will <strong>only</strong> be called for the page that
    * will actually be rendered (and not, for example, on a page that
    * handled a postback and then navigated to a different page).  Customize
    * this method to allocate resources that will be required for rendering
    * this page.</p>
    */
   @Override
   public void prerender() {
   }

   /**
    * <p>Callback method that is called after rendering is completed for
    * this request, if <code>init()</code> was called (regardless of whether
    * or not this was the page that was actually rendered).  Customize this
    * method to release resources acquired in the <code>init()</code>,
    * <code>preprocess()</code>, or <code>prerender()</code> methods (or
    * acquired during execution of an event handler).</p>
    */
   @Override
   public void destroy() {
   }

   /**
    * <p>Return a reference to the scoped data bean.</p>
    *
    * @return reference to the scoped data bean
    */
   protected SessionBean1 getSessionBean1() {
      return (SessionBean1) getBean("SessionBean1");
   }

   /**
    * <p>Return a reference to the scoped data bean.</p>
    *
    * @return reference to the scoped data bean
    */
   protected RequestBean1 getRequestBean1() {
      return (RequestBean1) getBean("RequestBean1");
   }

   /**
    * <p>Return a reference to the scoped data bean.</p>
    *
    * @return reference to the scoped data bean
    */
   protected ApplicationBean1 getApplicationBean1() {
      return (ApplicationBean1) getBean("ApplicationBean1");
   }

   //método para limpar campos
   public void limparCampos() {
      FacesContext.getCurrentInstance().getExternalContext().getRequestMap().clear();

      comboEstado.resetValue();
      comboEstado.setValue(new Integer(16));
      this.setCidades(new IceDecorator(CidadeBO.class).montaComboVinculado("estado", "codEstado",
              Integer.parseInt(comboEstado.getValue().toString())));
      comboCidade.setValue(new Integer(2788));
      comboAssociacao.resetValue();
      comboBanco.resetValue();
      comboTipoConta.resetValue();
      campoNumeroAssociado.resetValue();
      campoNome.resetValue();
      dateDataNascimento.resetValue();
      cpf.resetValue();
      comboSexo.resetValue();
      campoEmail.resetValue();
      campoTelefone.resetValue();
      campoCelular.resetValue();
      campoTelComercial.resetValue();
      campoEndereco.resetValue();
      campoBairro.resetValue();
      campoComplemento.resetValue();
      campoSitio.resetValue();
      campoCep.resetValue();
      campoAgencia.resetValue();
      campoNumero.resetValue();
      campoBusca.resetValue();
      botaoAlterar.setDisabled(true);
      setParar(false);
      ativo();
      habilitarCampos();
   }

   //método para habilitar campos
   public void habilitarCampos() {
      comboAssociacao.setDisabled(false);
      campoNumeroAssociado.setDisabled(false);
      campoNome.setDisabled(false);
      dateDataNascimento.setDisabled(false);
      cpf.setDisabled(false);
      comboSexo.setDisabled(false);
      campoEmail.setDisabled(false);
      campoTelefone.setDisabled(false);
      campoCelular.setDisabled(false);
      campoTelComercial.setDisabled(false);
      campoEndereco.setDisabled(false);
      campoBairro.setDisabled(false);
      campoComplemento.setDisabled(false);
      campoSitio.setDisabled(false);
      comboEstado.setDisabled(false);
      comboCidade.setDisabled(false);
      campoCep.setDisabled(false);
      comboBanco.setDisabled(false);
      comboTipoConta.setDisabled(false);
      campoAgencia.setDisabled(false);
      campoNumero.setDisabled(false);
   }

   //método para desabilitar campos
   public void desabilitarCampos() {
      comboAssociacao.setDisabled(true);
      campoNumeroAssociado.setDisabled(true);
      campoNome.setDisabled(true);
      dateDataNascimento.setDisabled(true);
      cpf.setDisabled(true);
      comboSexo.setDisabled(true);
      comboSexo.setVisible(true);
      campoEmail.setDisabled(true);
      campoTelefone.setDisabled(true);
      campoCelular.setDisabled(true);
      campoTelComercial.setDisabled(true);
      campoEndereco.setDisabled(true);
      campoBairro.setDisabled(true);
      campoComplemento.setDisabled(true);
      campoSitio.setDisabled(true);
      comboEstado.setDisabled(true);
      comboCidade.setDisabled(true);
      campoCep.setDisabled(true);
      comboBanco.setDisabled(true);
      comboTipoConta.setDisabled(true);
      campoAgencia.setDisabled(true);
      campoNumero.setDisabled(true);

   }

   //métodos para ativar associados
   public void ativo() {
      botaoDesativar.setImage("/resources/botaoInativo.png");
      botaoDesativar.setTitle("Desativar");
      imagemSituacao.setValue("/resources/botaoSituacaoAtivo.png");
      imagemSituacao.setTitle("Ativo");
   }

   //métodos para desativar associados
   public void inativo() {
      botaoDesativar.setImage("/resources/botaoAtivo.png");
      botaoDesativar.setTitle("Ativar");
      imagemSituacao.setValue("/resources/botaoSituacaoInativo.png");
      imagemSituacao.setTitle("Inativo");
   }
   
   //método de cadastro de um associado
   public String botaoCadastrar_action() {
      Associado ass = (Associado) getBean("Associado");      
      ass.setDataNasc(new ValidaFacade().consertarData(ass.getDataNasc()));
      Endereco end = (Endereco) getBean("Endereco");

      try {
         Cidade city = (Cidade) new IceDecorator(CidadeBO.class).retornaObjetoCodigo("codCidade",
                 Integer.parseInt(comboCidade.getValue().toString()));

         Associacao associacao = (Associacao) new IceDecorator(AssociacaoBO.class).retornaObjetoCodigo("codAssociacao",
                 Integer.parseInt(comboAssociacao.getValue().toString()));

         Banco banco = (Banco) new IceDecorator(BancoBO.class).retornaObjetoCodigo("codBanco",
                 Integer.parseInt(comboBanco.getValue().toString()));

         end.setCidade(city);
         ass.setBanco(banco);
         ass.setEndereco(end);
         ass.setAssociacao(associacao);
         ass.setTipoConta(comboTipoConta.getValue().toString());

         if (botaoDesativar.getImage().equals("/resources/botaoInativo.png")) {
            ass.setAtivo(true);
         } else {
            ass.setAtivo(false);
         }

         new IceDecorator(AssociadoBO.class).salvar(ass);

         limparCampos();
         painelMensagem.setRendered(true);

      } catch (Exception e) {
         e.printStackTrace();
         painelMensagem.setRendered(true);
         msgMensagemResultado.setValue("Erro ao efetuar operação");

      }
      return null;
   }

   //Action do botaoLimpar para limpar campos
   public String botaoLimpar_action() {
      habilitarCampos();
      limparCampos();
      return null;
   }

   //Action do botaoAlterar para alterar campos
   public String botaoAlterar_action() {
      setParar(true);
      habilitarCampos();
      return null;
   }

   //Action do botaoDesativar para desativar um associado
   public String botaoDesativar_action() {
      if (botaoDesativar.getImage().equals("/resources/botaoInativo.png")) {
         inativo();
         return null;
      } else if (botaoDesativar.getImage().equals("/resources/botaoAtivo.png")) {
         ativo();
         return null;
      }
      return null;
   }

   //Action do botaoSair para chamar o painel sair
   public String botaoSair_action() {
      limparCampos();
      painelSair.setRendered(true);


      return null;
   }

   //Action do botaoConsultar para chamar o painel consultar
   public String botaoConsultar_action() {
      limparCampos();
      painelConsulta.setRendered(true);
      return null;
   }

   //Action do botaoOkAviso para fechar o painelAviso e voltar ao painelConsulta
   public String botaoOkAviso_action() {

      painelAviso.setRendered(false);
      painelConsulta.setRendered(true);
      return null;
   }
   //Action do botaoNaoAviso para fechar os dois paineis

   public String botaoNaoAviso_action() {
      painelAviso.setRendered(false);
      painelConsulta.setRendered(false);
      return null;
   }

   //Action do botaoSairSim para retornar ao menu principal
   public String botaoSairSim_action() {
      //return null means stay on the same page
      return "menu";
   }

   //Action do botaoSairNao para voltar a tela de cadastro
   public String botaoSairNao_action() {
      painelSair.setRendered(false);
      return null;
   }

   //Action do botaoNovo para habilitar e limpar os campos
   public String botaoNovo_action() {
      habilitarCampos();
      limparCampos();
      return null;
   }

   //método para realizar uma consulta
   public String botaoConsultaOk_action() {

      try {
         Associado ass = (Associado) new IceDecorator(AssociadoBO.class).retornaObjeto("nome",
                 campoBusca.getValue().toString());
         limparCampos();

         setBean("Associado", ass);
         setBean("Endereco", ass.getEndereco());
         comboEstado.setValue(ass.getEndereco().getCidade().getEstado().getCodEstado());

         setCidades(new IceDecorator(CidadeBO.class).montaComboVinculado("estado", "codEstado",
                 Integer.parseInt(comboEstado.getValue().toString())));

         comboCidade.setValue(ass.getEndereco().getCidade().getCodCidade());
         comboBanco.setValue(ass.getBanco().getCodbanco());
         comboAssociacao.setValue(ass.getAssociacao().getCodAssociacao());

         desabilitarCampos();
         painelConsulta.setRendered(false);
         botaoAlterar.setDisabled(false);

         if (ass.getAtivo() == false) {
            inativo();
         } else {
            ativo();
         }

      } catch (Exception exc) {
         painelAviso.setRendered(true);
         msgAvisoResultado.setValue("Não houve resultados para a consulta");
      }
      return null;
   }

   //Action do botaoConsultaCancelar para fechar o painelConsulta
   public String botaoConsultaCancelar_action() {
      painelConsulta.setRendered(false);
      return null;
   }

   //Action do botaoAvisoSim para fechar o painelAviso
   public String botaoAvisoSim_action() {
      painelAviso.setRendered(false);
      return null;
   }

   //Action do botaoMensagemOk para fechar o painelMensagem
   public String botaoMensagemOk_action() {
      painelMensagem.setRendered(false);
      return null;
   }

   //Métodos para busca no banco de dados
   public void campoBusca_processValueChange(ValueChangeEvent vce) {
      try {
         this.setNomeBusca(new IceDecorator(AssociadoBO.class).consultaIncremental("nome", campoBusca.getValue().toString()));
      } catch (Exception e) {
      }
   }

   //Método para selecionar o estado desejado
   public void comboEstado_processValueChange(ValueChangeEvent vce) {
      this.setCidades(new IceDecorator(CidadeBO.class).montaComboVinculado("estado", "codEstado",
              Integer.parseInt(comboEstado.getValue().toString())));
   }

   //Método para validar o cpf
   public void validateCpf(FacesContext context, UIComponent component, Object value) {
      new ValidaFacade().validateCpf(context, component, value, AssociadoBO.class, parar);
   }

   //Action do botão para imprimir relatorio do associado corrente
   public String botaoImprimir_action() {
      ManipulaXML manipulaXML = new ManipulaXML();
      CriaQuery criaQuery = new CriaQuery();
      Relatorio relatorio = new Relatorio();
      try {
         manipulaXML.modificaXML("Relatorios\\AssociadoCompleto", criaQuery.criaQueryAssociadoCompleto(campoNome.getValue().toString(), campoNumeroAssociado.getValue().toString()));

         relatorio.geraJrprint("Relatorios\\AssociadoCompleto");
         relatorio.geraRelatorioPDF("Relatorios\\AssociadoCompleto");
         java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
         desktop.open(new File("Relatorios\\AssociadoCompleto.pdf"));
      } catch (ParserConfigurationException ex) {
         Logger.getLogger(AssociadoCadastrar.class.getName()).log(Level.SEVERE, null, ex);
      } catch (Exception ex) {
         Logger.getLogger(AssociadoCadastrar.class.getName()).log(Level.SEVERE, null, ex);
      }
      return null;
   }

   //validação de número associado
    public void campoNumeroAssociado_validate(FacesContext context, UIComponent component, Object value) {
        new ValidaFacade().validateNum(context, component, value, AssociadoBO.class, parar);
    }

   
}


